<?php


namespace app\api\model;


class WorkUserThumbsup extends BaseModel
{
    protected  $autoWriteTimestamp  = true;

    public function workUser(){
        return $this->belongsTo('WorkUser','wu_id','id')->field('id,name,head_img');
    }

    /**
     * 添加tian'z
     * @param $data
     * @return WorkUserThumbsup
     */
    public static function creatThumbsup($data){
        return self::create($data);
    }

    /**
     * 发现点赞
     * @param $log_id
     * @param $wu_id
     * @return array|false|\PDOStatement|string|\think\Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function findThumbsup($log_id,$wu_id){
        return self::where('wu_id','=',$wu_id)
                ->where('log_id','=',$log_id)->find();
    }

    /**
     * 获取点赞列表
     * @param $wu_id
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getList($id,$size,$page){
        return self::where('log_id','=',$id)
                ->with(['workUser'=>['userimg']])
                ->paginate($size,false,['page'=>$page]);
    }





}